package com.pe.cineplanet.proyectocine.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
 
import com.pe.cineplanet.proyectocine.domain.Pelicula;
import com.pe.cineplanet.proyectocine.repository.PeliculaRepository;


@Controller
public class DetallePeliculaController {
	private static final String PELICULAS = "peliculas";
	private static final String PELICULA = "pelicula";
	@Autowired
	PeliculaRepository daoPelicula;
	
   
	@RequestMapping(value="/vistaDetallePelicula", method=RequestMethod.GET)
	public @ModelAttribute("pelicula") Pelicula verDetallePelicula(@RequestParam("id_Pelicula") Integer id_Pelicula, Model model){
		
		Pelicula pelicula = daoPelicula.obtenerPelicula(id_Pelicula);
		model.addAttribute(PELICULA, pelicula);
		
		List<Pelicula> peliculas = daoPelicula.obtenerPeliculas();
		model.addAttribute(PELICULAS, peliculas);	
		
		
		
		return pelicula;
		
	}
	
	
	
	
}
